package com.axjy.cloud.weathe0309.controller;

import com.axjy.cloud.weathe0309.service.WeatherService;
import com.axjy.cloud.weathe0309.vo.WeatherResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Controller
@RestController
@RequestMapping("/weather")
public class WeatherController {

    @Resource
    private WeatherService weatherService;


    @GetMapping("/cityName/{cityName}")
    public WeatherResponse getWeatherByName(@PathVariable("cityName") String cityName){
        return weatherService.getDataByCityName(cityName);
    }

    @GetMapping("/cityKey/{cityKey}")
    public WeatherResponse getWeatherByKey(@PathVariable("cityKey") String cityKey){
        return weatherService.getDateByCityKey(cityKey);
    }



}
